starter.run(
	function($rootScope, $ionicPlatform) {

		// $ionicPlatform.ready(function () {

		//获取用户信息
		$rootScope.getUserData = function() {
			if ($rootScope.userData) {
				return $rootScope.userData;
			}
			var obj = localStorage.getItem("userData");
			if (obj) {
				$rootScope.userData = $.parseJSON(obj);
				return $rootScope.userData;
			}
			return null;
		};

		/*手机号码验证
		 * phone：手机号
		 * */
		$rootScope.telRuleCheck = function(phone) {
			var pattern = /^1[34578]\d{9}$/;
			if (pattern.test(phone)) {
				return true;
			}
			console.log('check mobile phone ' + phone + ' failed.');
			return false;
		};

		//日期时间转字符串 format：定义格式
		$rootScope.dateToStr = function(date, format) {
			var date_arr = {
				"M+": date.getMonth() + 1,
				"d+": date.getDate(),
				"h+": date.getHours(),
				"m+": date.getMinutes(),
				"s+": date.getSeconds(),
				"q+": Math.floor((date.getMonth() + 3) / 3),
				"S+": date.getMilliseconds()
			};
			if (/(y+)/i.test(format)) {
				format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
			}
			for (var k in date_arr) {
				if (new RegExp("(" + k + ")").test(format)) {
					format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date_arr[k] : ("00" + date_arr[k]).substr(("" + date_arr[k]).length));
				}
			}
			return format;
		}

		//字符串转date字符串格式yyyy-mm-dd
		$rootScope.strToDate = function(str_time) {
			// var new_str = str_time.replace(/:/g, '-');
			// new_str = new_str.replace(/ /g, '-');
			// var arr = new_str.split("-");
			// var strtotime = 0;
			// var datum = new Date(Date.UTC(arr[0], arr[1] - 1, arr[2], arr[3] - 8, arr[4], arr[5]));
			// if (datum != null && typeof datum != 'undefined') {
			//   strtotime = datum.getTime() / 1000;
			// }
			// return strtotime;

			var val = Date.parse(str_time);
			var newDate = new Date(val);
			return newDate;
		}
		// });
	});